<?php
    /**
     * Test base part site's functionality
     * Such as db connection, rights in directory and other...
     *
     */
    class siteTest extends WebTestCase {

        
    	/**
    	 * Test database connection 
    	 *
    	 */
        public function testDbConnect()
        {
            $this->assertTrue($this->get("http://{$_SERVER['SERVER_NAME']}/"));
        }


        /**
         * Check directories for rights permissions
         */
        public function testDirectoriesRights()
        {
            $path_to_check = array(
                'data/editor/cities' => '0777',
                'data/editor/news'   => '0777',
                'data/editor/pages'  => '0777',
                'data/prices'        => '0777',
        	);

            foreach ($path_to_check as $path => $permissions) {
            	$this->assertTrue(is_dir($path), "Directory '$path' not exists! %s");
            	if (is_dir($path)) {
            	  	$this->assertEqual(substr( sprintf( '%o', fileperms($path)), 1), $permissions, "Directory '$path' have incorect permissions! %s");
            	}
            }

        }

    }
 
